const log = require('../util/log'),
  config = require('../util/config'),
  sessionMng = require('./sessionMng')
var msgs = []

exports.add = msg => {
  if (config.domain == 'etourly.com') {
    return
  }
  msgs.push(msg)
  for (var sid in sessionMng.sessions) {
    sessionMng.sessions[sid].webSocket && sessionMng.sessions[sid].webSocket.send('log ' + JSON.stringify([msg]))
  }
}

exports.get = () => {
  return msgs
}

exports.del = index => {
  msgs.splice(index, 1)
  for (var sid in sessionMng.sessions) {
    sessionMng.sessions[sid].webSocket && sessionMng.sessions[sid].webSocket.send('delLog ' + index)
  }
}
